/************************************************************************
 ** This file is part of the network simulator Shawn.                  **
 ** Copyright (C) 2004-2007 by the SwarmNet (www.swarmnet.de) project  **
 ** Shawn is free software; you can redistribute it and/or modify it   **
 ** under the terms of the BSD License. Refer to the shawn-licence.txt **
 ** file in the root of the Shawn source tree for further details.     **
 ************************************************************************/
#ifndef __SHAWN_APPS_SHAWNBGU_PROCESSOR_PROCESSOR_H
#define __SHAWN_APPS_SHAWNBGU_PROCESSOR_PROCESSOR_H
#include "../../../buildfiles/_legacyapps_enable_cmake.h"
#ifdef ENABLE_SHAWNBGU

#include "shawnbgu_local_topology.h"
#include "sys/taggings/basic_tags.h"
#include "../../sys/processor.h"
#include "shawnbgu_message.h"
#include <set>
#include <vector>
#include <queue>

using namespace shawn;
using namespace std;

namespace shawnbgu
{

	class ShawnbguProcessor
	: public shawn::Processor
	{
	public:
		ShawnbguProcessor();
		virtual ~ShawnbguProcessor();

		const ShawnbguLocalTopology& local_topology();

		virtual void boot( void ) throw();
		virtual bool process_message( const ConstMessageHandle& ) throw();
		virtual void work( void ) throw();

		//virtual bool has_leader(void);
		//virtual Node* leader(void);
		//virtual void set_leader(Node*);
		/*virtual int get_distance_from_leader_(void);
		 virtual void set_distance_from_leader_(int);*/


	private:
		int diameter_;
		//int last_time_of_receive_;

		bool is_leader_;
		int leader_;
		int leadership_;

		ShawnbguLocalTopology local_topology_;
		queue<ShawnbguLocalTopology> neighbours_data_;
		queue<const ShawnbguMessage*> messages_;



		void init(void) throw();
		void update_local_topology();
		void find_leader();

		void log_neighbourhood();

	protected:
	            void write_int_tag( shawn::Node& node,
	                                const std::string& tag_name,
	                                int value ) throw();
	            void write_bool_tag( shawn::Node& node,
	            	                                const std::string& tag_name,
	            	                                bool value ) throw();


	};

}

#endif
#endif
/*-----------------------------------------------------------------------
 * Source  $Source: /cvs/shawn/shawn/apps/helloworld/helloworld_processor.h,v $
 * Version $Revision: 197 $
 * Date    $Date: 2008-04-29 18:40:51 +0300 (Tue, 29 Apr 2008) $
 *-----------------------------------------------------------------------
 * $Log: helloworld_processor.h,v $
 *-----------------------------------------------------------------------*/
